import { createStore } from 'vuex';
import createPersistedstate from 'vuex-persistedstate'; // vuex持久化插件
import user from '@/store/modules/user';
import cart from '@/store/modules/cart';
import category from '@/store/modules/category';

export default createStore({
	state: {},
	getters: {},
	mutations: {},
	actions: {},
	modules: {
		user,
		cart,
		category
	},
	plugins: [
		// 默认是存储在localStorage中
		// key是存储数据的键名
		// paths是存储state中的那些数据，如果是模块下具体的数据需要加上模块名称，如user.token
		createPersistedstate({
			key: 'erabbit-client-pc-store',
			paths: [ 'user', 'cart' ]
		})
	]
});
